﻿/*
 * Created by SharpDevelop.
 * User: xieen
 * Date: 2013-08-26
 * Time: 11:10
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace GoF23Learning._18.Memento_Pattern.Refactor
{
	/// <summary>
	/// Description of App.
	/// 处于另外的程序集
	/// </summary>
	public class App
	{
		//原发器对象
		Rectangle r = new Rectangle(0,0,10,20);
		//备忘录对象
		//保存原发器对象的内部状态
		MemoryStream rsaved = new MemoryStream();
		
		public void Process()
		{
			BinaryFormatter bf = new BinaryFormatter();
			bf.Serialize(rsaved,r);
		
 		
		}
		public void Save_Click(object sender,EventArgs args)
		{					
			BinaryFormatter bf = new BinaryFormatter();
			rsaved.Seek(0,SeekOrigin.Begin);
			r = (Rectangle) bf.Deserialize(rsaved);
			
		}
	}
}
